#include <bits/stdc++.h>
using namespace std;
#define int long long
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
    return x*f;
}
int a,b;
void solve(){
    a=read(),b=read();
    if(a<0) a=-a,b=-b;
    if((a>=0)==(b>=0)){
        cout<<"0\n";
        return;
    }
    cout<<min(abs(a+b),min(abs(a),abs(b)))<<"\n";
}
signed main(){
    freopen("sub.in","r",stdin);
    freopen("sub.out","w",stdout);
    int T=read();
    while(T--) solve();
    return 0;
}   